package ca.jsbr.canvaswar 
{
	import ca.jsbr.as2js_lib.display.canvas.Node2D;
	import ca.jsbr.as2js_lib.display.canvas.view.DebugView;
	import ca.jsbr.as2js_lib.event.BasicEvent;
	import ca.jsbr.as2js_lib.utils.assets.AssetsFactory;
	import ca.jsbr.canvaswar.screen.Screens;
	import ca.jsbr.canvaswar.ScreenManager;
	import flash.events.Event;
	/*window.requestAnimFrame = window.requestAnimationFrame || 
			   window.webkitRequestAnimationFrame ||
			   window.mozRequestAnimationFrame ||
			   window.oRequestAnimationFrame ||
			   window.msRequestAnimationFrame 
	*/
	/**
	 * ...
	 * @author jsbr [me@jsbr.ca]
	 */
	public class CanvasWar extends Node2D 
	{

		public function CanvasWar() 
		{
			_name = "CanvasWar";
		}
		
		public function init():void
		{
			
			AssetsFactory.getInstance().load("assets/canvaswar/asset.xml");
			AssetsFactory.getInstance().addEventListener(BasicEvent.READY, onAssetReady);
		}
		
		private function onAssetReady(e:Event):void 
		{
			start();
		}
		
		
		public function start()
		{
			addChild(ScreenManager.getInstance().root);
			ScreenManager.getInstance().setScreensObject(new Screens());
			ScreenManager.getInstance().openScreen(Screens.HOME_SCREEN);
			addChild(new DebugView());
		}
		
	}

}